<?php
/*******************************************************
*
* Page:    app_cache.class
* Author:  Matthew Sturges (matt@matthewsturges.com)
* Purpose: Provides a persistent array of settings information
* Created: 06/29/05
* Version: 2.0
*
* Modified:
*    01/01/05 AAA  Sample modification notes
*
*******************************************************/



class app_cache {
    var $values;

    function app_cache(){
        //Check to see if the cache exists. If not, create it.
        $filename = $_SERVER['DOCUMENT_ROOT'] . '/' . APP_CACHE_FILE;
        if (!file_exists($filename)){
            $a = array();
            $f = serialize($a);
            app_lib::create_file($filename, $f);
        }

        $f = app_lib::get_file(APP_CACHE_FILE);
        $this->values = unserialize($f);
    }

    function persist_cache(){
        $f = serialize($this->values);
        app_lib::put_file(APP_CACHE_FILE, $f);
    }

    function get_setting($key){
        $value = $this->values[$key];
        return $value;
    }

    function put_setting($key, $value){
        $this->values[$key] = $value;
        $this->persist_cache();
    }

}//end class clsConfig